<?php 
namespace app\admin\controller;
use think\Controller;
use think\Session;
use app\admin\controller\Base;
use think\Request;

class Base extends Controller
{
	protected $beforeActionList = ['first','second'];

    protected function first()
    {
        if(!session('?admin')){
            
            $this->error('请先登录','admin/Index/index');
        }
        
    }

    protected function second()
    {
        $request= Request::instance();
        $mname=$request->module();
        $cname=$request->controller();
        $aname=$request->action();
        // dump($mname);
        // dump($cname);
        // dump($aname);
        
        $zong = Session::get('admin.node');
        foreach($zong as $k => $v){
            $zong[$k] = strtolower($v);
        }
        // dump($zong);die;
        $quanxian = strtolower($cname.'/'.$aname);
        
        if(empty($zong)||!in_array($quanxian,$zong)){
            $this->error('您没有权限操作','admin/Main/index');
        }
        	
        

    }


}